package com.tuju.jetpackfirstdemo.ui.room_demo

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.tuju.jetpackfirstdemo.data.room.UserDao

class RoomViewModelFactory(private val dataSource: UserDao) : ViewModelProvider.Factory {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        if (modelClass.isAssignableFrom(RoomViewModel::class.java)) {
            return RoomViewModel(dataSource) as T
        }
        throw IllegalArgumentException("Unknown ViewModel class")
    }
}